import { reqGetSearchGoodsInfoData } from '../../api/index';

const state = {
    goodsInfo: [],
};

const actions = {
    async getSearchGoodsInfoData({ commit }, SearchParams) {
        let result = await reqGetSearchGoodsInfoData(SearchParams);
        if (result.code === 200) {
            commit('SAVE_SEARCH_GODDS_INFO_DATA', result.data);
        } else {
            console.log(result.message);
        }
    },
};

const mutations = {
    SAVE_SEARCH_GODDS_INFO_DATA(state, goodsInfo) {
        state.goodsInfo = goodsInfo;
    },
};

const getters = {
    goodsList(state) {
        return state.goodsInfo.goodsList;
    },
    attrsList(state) {
        return state.goodsInfo.attrsList;
    },
    trademarkList(state) {
        return state.goodsInfo.trademarkList;
    },
    total(state) {
        return state.goodsInfo.total;
    },
};

export default {
    //开启命名空间
    namespaced: true,
    state,
    actions,
    mutations,
    getters,
};
